import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'package:flutter_account_book/utils/db/db_helper.dart';

import 'routes.dart';
import 'generated/l10n.dart';
import 'splash/index.dart';
import 'splash/binding.dart';
import 'themes/index.dart';

void main() {
  //解决Unhandled Exception: Binding has not yet been initialize
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

// {
//   '/device_info': (BuildContext context) => const DeviceInfoPage(),
//   '/image_picker': (BuildContext context) => const ImagePickerPage(),
//   '/location': (BuildContext context) => const LocationPage(),
//   '/contacts': (BuildContext context) => const ContactsPage(),
//   '/contacts/list': (BuildContext context) => ContactListPage(),
//   '/contacts/picker': (BuildContext context) => const ContactsPage(),
//   '/sound': (BuildContext context) => const SimpleRecorderPage(),
//   '/native': (BuildContext context) => const NativePage(),
//   '/web': (BuildContext context) => const WebViewPage(),
//   '/web-off': (BuildContext context) => const OfflineDownloadPage(),
//   '/web-off/page': (BuildContext context) {
//     Map<String, String> passValue =
//         ModalRoute.of(context)?.settings.arguments as Map<String, String>;
//     String filePath = passValue['filePath'] ?? '';
//     return OfflineWebViewPage(filePath: filePath);
//   },
//   '/login': (BuildContext context) => const LoginPage(),
//   '/login2': (BuildContext context) => const Login2Page(),
// }
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    DbHelper.instance();
    return GetMaterialApp(
      title: 'Flutter Demo',
      locale: const Locale('zh', 'CN'),
      localizationsDelegates: const [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: S.delegate.supportedLocales,
      theme: Themes.light,
      darkTheme: Themes.dark,
      getPages: Routers.routes,
      initialBinding: SplashBinding(),
      home: const SplashPage(),
    );
  }
}
